import request from "@/api/request.js"
import {usetokenstore} from "@/store/token.js";

export const insertItemService = (bookId)=>{
    const params = new URLSearchParams()
    const tokenstore=usetokenstore();

    params.append("bookId",bookId)
    return request.post("/item/insertIntoItem",params,{headers:{'jwt':tokenstore.token}})
}

export const getItemDetailService=()=>{
    const tokenstore=usetokenstore();

    return request.post("/item/getItemDetail",null,{headers:{'jwt':tokenstore.token}})
}

export const addItemService=(itemId,bookId)=>{
    const tokenstore = usetokenstore();

    const params = new URLSearchParams()
    params.append("itemId",itemId)
    params.append("bookId",bookId)
    return request.post("/item/addItem",params,{headers:{'jwt':tokenstore.token}})
}

export const subItemService=(itemId)=>{
    const tokenstore = usetokenstore();

    const params = new URLSearchParams()
    params.append("itemId",itemId)
    return request.post("/item/subItem",params,{headers:{'jwt':tokenstore.token}})
}

export const deleteItemService=(itemId)=>{
    const tokenstore = usetokenstore();
    const params = new URLSearchParams();
    params.append("itemId",itemId)

    return request.post("/item/deleteItem",params,{headers:{'jwt':tokenstore.token}})
}